﻿// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace JumpstartApp.Views
{
    using System;

    using Windows.Storage;
    using Windows.UI.Xaml;

    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class AppHub : Helpers.LayoutAwarePage
    {
        public AppHub()
        {
            this.InitializeComponent();
            this.Loaded += this.AppHub_Loaded;
        }

        async void AppHub_Loaded(object sender, RoutedEventArgs e)
        {
            // UpdateSilhouette
            var _UpdateSilhouette = new Action(async () =>
            {
                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    this.MySilhouette.ShowGuide = Contracts.Settings.ShowSilhouette;
                });
            });
            ApplicationData.Current.DataChanged += (s, arg) => _UpdateSilhouette();
            _UpdateSilhouette();

            await (this.DataContext as ViewModels.AppHubViewModel).Start(this);

            this.ZoomedOutGridView.ItemsSource = this.CVS4Landscape.View.CollectionGroups;
        }

    }
}
